#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<set>
using namespace std;
// #define EVALRPN
#ifdef EVALRPN
class Solution {
public:
    int calculate(int&left, int&right, string&oper)
    {
        switch(oper[0])
        {
            case '+':
                return left+right;
            case '-':
                return left-right;
            case '*':
                return left*right;
            case '/':
                return left/right;
            default:
                return -1;
        }
    }
    int evalRPN(vector<string>& tokens) {
        stack<int>st;
        set<string>s={"+","-","*","/"};
        for(auto&str:tokens)
        {
            if(s.count(str))
            {
                int right=st.top();
                st.pop();
                int left=st.top();
                st.pop();
                st.push(calculate(left,right,str));     
            }
            else
                st.push(stoi(str));
        }
        return st.top();
    }
};
#endif